package com.elong.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.elong.common.util.StringUtils;

public class URLParamUtil {

    public static  Map<String, String> parseUrl(String url){
	Map<String, String> paramMap= new HashMap<>();
	String paramPart = url.substring(url.indexOf("?") + 1);
	if(StringUtils.isNotBlank(paramPart)){
	    String[] keyValuePart = paramPart.split("&");
	    for(String keyValue : keyValuePart){
		String[] keyValueString = keyValue.split("=");
		paramMap.put(keyValueString[0], keyValueString[1]);
	    }
	}
	return paramMap;
    }
    
    public static void main(String[] args) {
	Map<String, String> paramMapList = parseUrl("http://127.0.0.1:8200/ihotel-h5/order/fill?hotelId=324748&roomId=200761864&productId=200761864&checkInDate=2015-04-14&checkOutDate=2015-04-15&otaId=2&elongPid=17052777978034413398&productSign=2494558723391379239&roomInfoStr=1|2");
	System.out.println(JSON.toJSONString(paramMapList));
    }
}
